<?php

vendor('csv');

$file = '';
if (count($list->rows)) {
	$rows = array();

	$row = array();
	$row[] = __d($po_domain, 'surname', true);
	$row[] = __d($po_domain, 'name', true);
	$row[] = __d($po_domain, 'group', true);
	$row[] = __d($po_domain, 'email', true);
	$row[] = __d($po_domain, 'created_date', true);

	$rows[] = $row;

    foreach ($list->rows as $item) {
    	$row = array();
		$row[] = $item[$modelName]['surname'];
		$row[] = $item[$modelName]['name'];
		$row[] = $item['Group']['name'];
		$row[] = $item[$modelName]['email'];
		$row[] = Date::Short(DATE::SQL2UNIX($item[$modelName]['created']));

    	$rows[] = $row;
    }

    foreach ($rows as $row) {
        $file .= csv::drawLine($row);
    }
}

header("Content-Length: ".strlen($file));

echo $file;

?>